import {reqUserAddress,reqTradeInfo} from '@/api'
import { Message  } from 'element-ui'
const actions = {
    async getUserAddress({commit}){
        const result = await reqUserAddress()
        if (result.code ===200){
            commit('SAVE_USER_ADDRESS',result.data)
        }else{
            Message.error(result.message)
        }
    },
    async getTradeInfo({commit}){
        const result = await reqTradeInfo()
        if (result.code ===200){
            commit('SAVE_TRADE_INFO',result.data)
        }
    }
}
const mutations = {
    SAVE_USER_ADDRESS(state,list){
        state.userAddress =list

    },
    SAVE_TRADE_INFO(state,list){
        state.tradeInfo =list
    }
}
const state = {
    userAddress:[],
    tradeInfo:[]
}
const getters = {}

export default {
    namespaced:true,
    actions,
    mutations,
    state,
    getters,
}